home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-05-19 | 39.8 KB | 1,655 lines |
- Newsgroups: comp.sources.misc
- From: tony@ajfcal.UUCP (Tony Field)
- subject: v12i107: psf2.0 source 4/6
- Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
-
- Posting-number: Volume 12, Issue 107
- Submitted-by: tony@ajfcal.UUCP (Tony Field)
- Archive-name: psf2/part04
-
- psf2.0 source 4/6
- =================
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 4 (of 6)."
- # Contents: Install.unix psbanner.c psd.c table.c
- # Wrapped by ajf@trifid on Tue May 15 01:10:49 1990
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'Install.unix' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Install.unix'\"
- else
- echo shar: Extracting \"'Install.unix'\" \(10530 characters\)
- sed "s/^X//" >'Install.unix' <<'END_OF_FILE'
- X:
- X# Install psf filters on AT&T Unix 3.2.2 (install.unix)
- X#
- X# NOTE: if a different version of unix is used, this script
- X# may need modification.....
- X#
- X# If AT&T Unix 3.2.2 is used and FACE is available, then
- X# the FACE printer database can be updated if the
- X# option "-f" is provided on the command line. The -f
- X# should be used for both installation and removal of psf.
- X#
- X# Install.unix -f
- X#
- X# note: this script records configuration parameters in
- X# various ".cfg" files in the current directory.
- X# it also expects some .cfg files to be created
- X# by "selectdef".
- X
- XPATH=.:/bin:/usr/bin:/etc
- X
- X# ----------------------------------------------
- X# beginning of things that may need modification
- X
- X
- X# Define the destination directory of the psf binaries and scripts
- X# and the print spooler directory
- X
- XBINDIR="/usr/local/bin"
- XSPOOLDIR="/usr/spool/lp"
- X
- X# Unix lp printer systems files...
- X# The directory structure follows AT&T unix 3.2.2 conventions.
- X# Other unix systems may be different.
- X# If you are not using AT&T Unix with FACE installed, then
- X# ignore the reference to DATABASE.
- X
- XDEFDIR="/usr/spool/lp/model/psfprint.def"
- XMODEL="$SPOOLDIR/model"
- XDATABASE="/usr/vmsys/admin/PS/PORTSET/database"
- X
- X# Specify the man pages directory. If you are using a system
- X# without man pages, ignore these entires.
- X#
- X# Xenix uses man directories that look like /usr/man/man.1
- X# If your directories do NOT use the dot (e.g. man1)
- X# format, then remove the "." in the definitions below.
- X
- XMANDIR="/usr/man/man."
- XCATDIR="/usr/man/cat."
- XMANCHAP="1"
- X
- X# ------------------------------------------
- X# The following should not need modification
- X
- XDEFFILES="defs/*.def"
- XPAGESIZE="undefined"
- XPNAME="undefined"
- XMODELNAME="psf"
- X
- X# Create an entry line that will go into the FACE printer
- X# selection data base in $DATABASE (for AT&T unix 3.2.2)
- X# If the $DATABASE file does not exist, then the following
- X# is ignored.
- X
- XPRINTERDBS="Postscript-PSF 435_table psf postscript tabs ixon ixoff onlcr"
- XPRINTERID="Postscript-PSF"
- X
- Xcase ${1} in
- X-f) ;;
- X*) DATABASE="z9+notHeRe"
- X ;;
- Xesac
- X
- X# PSF distribution files
- X
- XBINARIES="psf pnf pmf psd psbanner psdetect"
- XMANS="psf.1 pnf.1 pmf.1 psd.1 psmbox.1 psman.1 psnroff.1"
- XDOCS="psf.doc pnf.doc pmf.doc psd.doc psmbox.doc psman.doc psnroff.doc"
- XSCRIPTS="psmbox psman psmandouble psnroff"
- X
- X# See if the man-page directory really exists
- X
- XHAVEMAN=
- Xif test ! -d $MANDIR$MANCHAP
- Xthen
- X MANCHAP="Not.Allowed"
- X HAVEMAN="(missing directory)"
- Xfi
- X
- X# get existing psf installation parameters
- X
- Xif test -f Pmanchap.cfg
- Xthen
- X MANCHAP=`cat -s Pmanchap.cfg`
- Xfi
- X
- Xif test -f Pbindir.cfg
- Xthen
- X BINDIR=`cat -s Pbindir.cfg`
- Xfi
- X
- Xif test -f PPagesize.cfg
- Xthen
- X PAGESIZE=`cat -s Ppagesize.cfg`
- Xfi
- Xif test -f Ppsfprint.cfg
- Xthen
- X PNAME=`cat -s Ppsfprint.cfg`
- Xfi
- X
- X# Define return values
- X
- X: ${OK=0} ${FAIL=1} ${STOP=10} ${HALT=11}
- X
- X
- X# Print an error message
- Xerror() {
- X echo "\nError: $*" >&2
- X return 1
- X}
- X
- X# Prompt with mesg, return non-zero on q
- Xprompt() {
- X while echo "\n${mesg}or enter q to $quit: \c" >&2
- X do read cmd
- X case $cmd in
- X +x|-x) set $cmd ;;
- X Q|q) return 1 ;;
- X !*) eval `expr "$cmd" : "!\(.*\)"` ;;
- X "") # If there is an argument use it as the default
- X # else loop until 'cmd' is set
- X [ "$1" ] && {
- X cmd=$1
- X return 0
- X }
- X : continue
- X ;;
- X *) return 0 ;;
- X esac
- X done
- X}
- X
- X
- Xshowstats () {
- X echo "\nPSF INSTALLATION OPTIONS SELECTED"
- X echo "--------------------------------"
- X echo "printer selected from: $PNAME"
- X echo "printer page size is: $PAGESIZE"
- X echo "psf default options: $PSFOPT"
- X echo "banner options: $BANNEROPT"
- X echo "binaries and scripts in: $BINDIR"
- X echo "man pages in chapter: $MANCHAP"
- X}
- X
- X# Copy the psf binares and scripts to target binary directory
- X
- Xcreateprinter () {
- X bdir="$BINDIR"
- X echo " "
- X echo "Install PSF binaries and"
- X ./query " scripts in which directory [$bdir]? "
- X read bdir
- X case "$bdir" in
- X '') ;;
- X *) BINDIR="$bdir"
- X ;;
- X esac
- X if test ! -d $BINDIR
- X then
- X echo "\nDirectory $BINDIR does not exist."
- X echo "Create the directory and re-start the installation.\n"
- X exit $FAIL
- X fi
- X echo "$BINDIR" > Pbindir.cfg
- X cp $BINARIES $BINDIR
- X cp $SCRIPTS $BINDIR
- X rm -f psf.model
- X sed "s@BINARY@$BINDIR@g" psfunix.LP | sed "s@OPTIONS@$PSFOPT@g" \
- X | sed "s@BANNER@$BANNEROPT@g" > psf.model
- X chmod +rw psf.model
- X echo "psf binaries and scripts have been copied to $BINDIR"
- X showstats
- X return 0
- X}
- X
- X
- X# Copy the psf model and control files to the spool directory.
- X
- Xmovefiles () {
- X cp psf.model $MODEL/$MODELNAME
- X cp $PNAME $DEFDIR
- X chown lp $MODEL/$MODELNAME $DEFDIR
- X chgrp bin $MODEL/$MODELNAME $DEFDIR
- X
- X# If the FACE printer database exits, add the user provided the
- X# -u option, then add a postscript printer to the database
- X
- X
- X if test -f $DATABASE
- X then
- X echo "$PRINTERDBS" >> $DATABASE
- X echo "FACE printer file $DATABASE",
- X echo " has been updated with a psf printer definition."
- X fi
- X echo "lp spooler files are copied to:"
- X echo " $MODEL/$MODELNAME"
- X echo " $DEFDIR"
- X showstats
- X return 0
- X}
- X
- X
- X# Set up default page sizes for psf to be placed in the
- X# lp spooling script files
- X
- Xgetsizes () {
- X PAGESIZE=`cat -s Ppagesize.cfg`
- X PNAME=`cat -s Ppsfprint.cfg`
- X cp $PNAME psfprint.def
- X case $PAGESIZE in
- X DEFAULT) PSFOPT= ;;
- X *) PSFOPT=`echo -g $PAGESIZE` ;;
- X esac
- X case $PAGESIZE in
- X DEFAULT) BANNEROPT= ;;
- X *) BANNEROPT=`echo -g $PAGESIZE` ;;
- X esac
- X return 0
- X}
- X
- Xreplaceprinter () {
- X selectdef $DEFFILES
- X case $? in
- X 0) ;;
- X *) return $?
- X esac
- X getsizes
- X return 0
- X}
- X
- X
- Xmanpages () {
- X echo "\nNormally, man pages are not installed in AT&T unix 3.2.* systems."
- X echo "If you have an on-line man system using 'man', then you may proceed"
- X echo "with the man page installation. If you do not have the man system,"
- X echo "then specify 'none' for the man page chapter..."
- X cdir="$MANCHAP"
- X echo " "
- X ./query "Which chapter should be used for the PSF man pages [$cdir]? "
- X read cdir
- X case "$cdir" in
- X '') ;;
- X none) return 0
- X ;;
- X *) MANCHAP="$cdir"
- X ;;
- X esac
- X if test ! -d $MANDIR$MANCHAP
- X then
- X echo "\nDirectory $MANDIR$MANCHAP does not exist."
- X echo "Select a different directory or quit and create the"
- X echo "desired directory.\n"
- X return 0
- X fi
- X
- X cp pmf.1 $MANDIR$MANCHAP/pmf.$MANCHAP
- X cp pnf.1 $MANDIR$MANCHAP/pnf.$MANCHAP
- X cp psf.1 $MANDIR$MANCHAP/psf.$MANCHAP
- X cp psd.1 $MANDIR$MANCHAP/psd.$MANCHAP
- X cp psman.1 $MANDIR$MANCHAP/psman.$MANCHAP
- X cp psnroff.1 $MANDIR$MANCHAP/psnroff.$MANCHAP
- X cp psmbox.1 $MANDIR$MANCHAP/psmbox.$MANCHAP
- X man $MANCHAP pmf > /dev/null
- X man $MANCHAP pnf > /dev/null
- X man $MANCHAP psd > /dev/null
- X man $MANCHAP psf > /dev/null
- X man $MANCHAP psman > /dev/null
- X man $MANCHAP psnroff > /dev/null
- X man $MANCHAP psmbox > /dev/null
- X echo "$MANCHAP" > Pmanchap.cfg
- X echo "\nPSF man pages have been installed in $MANDIR$MANCHAP"
- X return 0
- X}
- X
- X# if the man-page directory exists print the manuals with
- X# nroff output. if it does not exist, print from the
- X# pre-formatted print files (using psf, of course...)
- X# If the man page directory exists, ASSUME that nroff also exists...
- X
- Xprintman () {
- X if test ! -d $MANDIR$MANCHAP
- X then
- X psf -2l 66 $DOCS | lp
- X else
- X psnroff -man $MANS
- X fi
- X return 0
- X}
- X
- Xremoveall () {
- X cdir="$MANCHAP"
- X echo " "
- X ./query "Remove PSF man pages from chapter [$cdir]? "
- X read cdir
- X case "$cdir" in
- X '') ;;
- X *) MANCHAP="$cdir"
- X ;;
- X esac
- X if test ! -d $MANDIR$MANCHAP
- X then
- X echo "\nDirectory $MANDIR$MANCHAP does not exist."
- X exit $FAIL
- X fi
- X
- X bdir="$BINDIR"
- X echo " "
- X ./query "Remove PSF binaries+scripts from directory [$bdir]? "
- X read bdir
- X case "$bdir" in
- X '') ;;
- X *) BINDIR="$bdir"
- X ;;
- X esac
- X if test ! -d $BINDIR
- X then
- X echo "\nDirectory $BINDIR does not exist."
- X exit 1
- X fi
- X
- X rm -f $MANDIR$MANCHAP/pmf.$MANCHAP
- X rm -f $MANDIR$MANCHAP/pnf.$MANCHAP
- X rm -f $MANDIR$MANCHAP/psf.$MANCHAP
- X rm -f $MANDIR$MANCHAP/psd.$MANCHAP
- X rm -f $MANDIR$MANCHAP/psman.$MANCHAP
- X rm -f $MANDIR$MANCHAP/psnroff.$MANCHAP
- X rm -f $MANDIR$MANCHAP/psmbox.$MANCHAP
- X
- X rm -f $CATDIR$MANCHAP/pmf.$MANCHAP
- X rm -f $CATDIR$MANCHAP/pnf.$MANCHAP
- X rm -f $CATDIR$MANCHAP/psf.$MANCHAP
- X rm -f $CATDIR$MANCHAP/psd.$MANCHAP
- X rm -f $CATDIR$MANCHAP/psman.$MANCHAP
- X rm -f $CATDIR$MANCHAP/psnroff.$MANCHAP
- X rm -f $CATDIR$MANCHAP/psmbox.$MANCHAP
- X
- X thisdir=`pwd`
- X
- X cd $BINDIR
- X rm $BINARIES $SCRIPTS
- X
- X cd $thisdir
- X
- X rm $MODEL/$MODELNAME
- X rm $DEFDIR
- X
- X# If the FACE printer database exits, remove the psf printer
- X#NOTE should test to ensure that the copy was OK
- X#^^^^
- X# if test -f $PRINTERDBS
- X# then
- X# grep -v "$PRINTERID" $DATABASE > /tmp/Pdbs.Temp.Q
- X# cp /tmp/Pdbs.Temp.Q $DATABASE
- X# fi
- X if test -f $DATABASE
- X then
- X grep "$PRINTERID" $DATABASE > /dev/null
- X case $? in
- X 0) echo "\nThe FACE printer data base file:"
- X echo " $DATABASE"
- X echo "should be manually edited to remove the reference to the"
- X echo "psf printer identified as $PRINTERID"
- X ;;
- X *) ;;
- X esac
- X fi
- X
- X return 0
- X}
- X
- X
- X#
- X# main()
- X#
- Xecho "\n\tPSF: Postscript print filter installation\n"
- Xecho "Please ensure that the binary directory and other file references"
- Xecho "are consistent between this install script and the Makefile.\n"
- Xecho "NB: Install the printer with FACE and/or lpadmin befor printing manuals.\n"
- Xecho "Some of the following defaults (+) may be modified during installation.\n"
- Xecho "+ Binary directory: $BINDIR"
- Xecho " Spooling directory: $SPOOLDIR"
- Xecho " Printer model file: $MODEL/$MODELNAME"
- Xecho " Printer model name: $MODELNAME"
- Xif test -f $DATABASE
- Xthen
- X echo " FACE printer database file: $DATABASE"
- X echo " Printer title in FACE is: $PRINTERID"
- Xfi
- X
- Xif test -d $MANDIR$MANCHAP
- Xthen
- X echo "+ Man-page directory: $MANDIR$MANCHAP"
- X if test -d $CATDIR$MANCHAP
- X then
- X echo " $CATDIR$MANCHAP"
- X fi
- Xfi
- X
- Xwhile
- X mesg="\t1. Select printer type, make printer model files
- X 2. Move psf binaries and scripts to $BINDIR
- X 3. Move psf files to $SPOOLDIR
- X 4. Install man pages in $MANDIR$MANCHAP $HAVEMAN
- X 5. Print man pages
- X 6. Remove psf software and files from binary and spool directories
- X
- XSelect an option "
- X quit=quit
- Xdo
- X prompt
- X choice=$cmd
- X quit="return to the previous menu"
- X case $choice in
- X 1) replaceprinter
- X ;;
- X 2) [ -r Ppagesize.cfg ] && [ -r Ppsfprint.cfg ] && [ -r $PNAME ] && createprinter
- X ;;
- X 3) movefiles
- X ;;
- X 4) manpages
- X ;;
- X 5) printman
- X ;;
- X 6) removeall
- X ;;
- X [qQ]) break ;;
- X *) error "unknown option: \"$choice\""
- X ;;
- X esac
- Xdone
- Xexit $OK
- END_OF_FILE
- if test 10530 -ne `wc -c <'Install.unix'`; then
- echo shar: \"'Install.unix'\" unpacked with wrong size!
- fi
- chmod +x 'Install.unix'
- # end of 'Install.unix'
- fi
- if test -f 'psbanner.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'psbanner.c'\"
- else
- echo shar: Extracting \"'psbanner.c'\" \(7088 characters\)
- sed "s/^X//" >'psbanner.c' <<'END_OF_FILE'
- X/* ta=4 */
- X/****************************************************************************
- X* p s b a n n e r . c v 2.0 *
- X* *
- X* Print a banner page on a postscript printer for Xenix 2.2.3 *
- X* *
- X* The generated print stream is NOT minimally conforming as per Red Book. *
- X* *
- X* Tony Field. tony@ajfcal *
- X****************************************************************************/
- X
- X#include <stdio.h>
- X#include "patchlevel.h"
- X
- X
- X/* setup paper dimensions */
- X
- Xtypedef struct /* measurement in point */
- X{ char paper_name[60]; /* name of paper size (for command line) */
- X char paper_tray[200]; /* postscript operator to select this tray */
- X int width; /* portrait point width of paper */
- X int height; /* portrait point height of paper */
- X int lx, ly, ux, uy;
- X} measure;
- X
- Xmeasure *p; /* working set of parameters (points to something below) */
- X
- X /* standard paper sizes in portrait layout. */
- X
- Xmeasure page_types[30] =
- X{ { "letter",
- X "statusdict begin lettertray end",
- X 612, 792, 18, 15, 593, 777
- X },
- X { "legal",
- X "statusdict begin legaltray end",
- X 612, 1008, 18, 15, 593, 993
- X },
- X { "a4",
- X "statusdict begin a4tray end",
- X 595, 842, 18, 15, 578, 827
- X },
- X { "b5",
- X "statusdict begin b5tray end",
- X 516, 729, 18, 15, 497, 712
- X },
- X { "", /* end of paper list */
- X "",
- X 0, 0, 0, 0, 0, 0
- X }
- X};
- X
- Xchar slots[4][100] =
- X{ "statusdict begin 1 setpapertray end",
- X "statusdict begin 2 setpapertray end",
- X "",
- X ""
- X} ;
- Xint nslots = 2;
- X
- Xint X_INDENT = 30; /* points */
- Xint Y_INDENT = 30;
- Xint BIG_POINT = 60; /* changes to point size automatically scale */
- Xint MED_POINT = 35; /* the printout. */
- Xint SMALL_POINT = 15;
- Xint UX, UY, DX, DY, MAX_X, MAX_Y;
- X
- X/* The following arguments are received in the command line
- X argvp[9] and argv[10] may be page size and paper tray specifications.
- X*/
- X
- X#define Userid argv[1]
- X#define Name argv[2]
- X#define Requestid argv[3]
- X#define Printer argv[4]
- X#define Options argv[5]
- X#define Date argv[6]
- X#define Machineid argv[7]
- X#define Title argv[8]
- X
- Xmain (argc, argv)
- Xint argc;
- Xchar *argv[];
- X{ int x, y, c, i, set_paper_tray, set_paper_bin;
- X char line[200];
- X FILE *pdef;
- X
- X if ((pdef = fopen (PDEF, "r")) != NULL)
- X { nslots = 0;
- X fgets (line, 199, pdef);
- X for (i = 0; i < 25; i++)
- X { if (fgets (line, 199, pdef) == NULL)
- X break;
- X trim (line);
- X if (strncmp (line, "*fonts", 6) == 0)
- X break;
- X strcpy (page_types[i].paper_name, line);
- X if (fgets (page_types[i].paper_tray, 199, pdef) == NULL)
- X bad_file();
- X trim (page_types[i].paper_tray);
- X if (fgets (line, 100, pdef) == NULL)
- X bad_file();
- X trim (line);
- X sscanf (line, "%d%d%d%d%d%d",
- X &page_types[i].width,
- X &page_types[i].height,
- X &page_types[i].lx,
- X &page_types[i].ly,
- X &page_types[i].ux,
- X &page_types[i].uy);
- X
- X }
- X page_types[i].paper_name[0] = '\0';
- X
- X while (fgets (line, 199, pdef) != NULL)
- X { if (strncmp (line, "*slots", 6) == 0)
- X { while (fgets (line, 90, pdef) != NULL)
- X { trim (line);
- X if (strncmp (line, "*eof", 4) == 0)
- X break;
- X if (*line)
- X { strcpy (slots[nslots], line);
- X if (++nslots > 3)
- X break;
- X }
- X }
- X }
- X }
- X fclose (pdef);
- X }
- X
- X MAX_X = page_types[0].width;
- X MAX_Y = page_types[0].height;
- X set_paper_bin = 0;
- X set_paper_tray = -1;
- X
- X for (i = 9; i < argc; i++)
- X { c = argv[i][1];
- X switch (c)
- X {
- X case 'b':
- X if ((set_paper_bin = atoi (argv[i+1])) > nslots)
- X { fprintf (stderr, "paper bin greater than %d\n", nslots);
- X exit (1);
- X }
- X i++;
- X break;
- X
- X case 'g':
- X for (set_paper_tray = 0; page_types[set_paper_tray].paper_name[0]; set_paper_tray++)
- X { if (compare (argv[i+1], page_types[set_paper_tray].paper_name) == 0)
- X { MAX_X = page_types[set_paper_tray].width;
- X MAX_Y = page_types[set_paper_tray].height;
- X break;
- X }
- X }
- X if (page_types[set_paper_tray].paper_name[0] == '\0')
- X { fprintf (stderr, "Invalid paper size\n");
- X exit (1);
- X }
- X i++;
- X break;
- X
- X default: ;
- X }
- X }
- X
- X UX = X_INDENT;
- X UY = (MAX_Y - Y_INDENT);
- X DX = (MAX_X - 2 * X_INDENT);
- X DY = (BIG_POINT * 3);
- X
- X /* center text used for userid and job title print */
- X
- X send ("%!\n");
- X send ("/ctext { % center text: string x y dx\n");
- X send (" 2 div\n");
- X send (" /Dx exch def\n");
- X send (" /Yv exch def\n");
- X send (" /Xv exch def\n");
- X send (" dup stringwidth pop\n");
- X send (" 2 div\n");
- X send (" Dx exch sub\n");
- X send (" Xv add\n");
- X send (" Yv moveto\n");
- X send (" show\n");
- X send ("} def\n");
- X send ("%%EndProlog\n");
- X
- X send ("%%Page: ? 1\n");
- X if (set_paper_bin)
- X printf ("%s\n", slots[set_paper_bin-1]);
- X
- X if (set_paper_tray >= 0)
- X printf ("%s\n", page_types[set_paper_tray].paper_tray);
- X
- X send ("/pg save def\n");
- X
- X /* draw a box for the userid */
- X
- X printf ("newpath\n");
- X printf ("%d %d moveto\n", UX,UY);
- X printf ("%d %d rlineto\n", DX, 0);
- X printf ("%d %d rlineto\n", 0, -DY);
- X printf ("%d %d rlineto\n", -DX, 0);
- X printf ("closepath\n");
- X printf ("4 setlinewidth\n");
- X printf ("stroke\n");
- X
- X /* center the userid and the job title */
- X
- X y = UY - DY / 2 - BIG_POINT / 2;
- X printf ("/Helvetica-BoldOblique findfont %d scalefont setfont\n", BIG_POINT);
- X printf ("(%s) %d %d %d ctext\n", Userid, X_INDENT, y, DX);
- X
- X y = UY - (DY + MED_POINT * 3);
- X printf ("/Helvetica-Bold findfont %d scalefont setfont\n", MED_POINT);
- X printf ("(%s) %d %d %d ctext\n", Title, X_INDENT, y, DX);
- X
- X /* print other banner page parameters */
- X
- X x = X_INDENT;
- X y -= (MED_POINT * 2);
- X printf ("%d %d moveto\n", x,y);
- X sendnormal ("User: ");
- X sendbold (Name);
- X
- X y -= SMALL_POINT + (SMALL_POINT / 2);
- X printf ("%d %d moveto\n", x,y);
- X sendnormal ("Request ID: ");
- X sendbold (Requestid);
- X
- X y -= SMALL_POINT + (SMALL_POINT / 2);
- X printf ("%d %d moveto\n", x,y);
- X sendnormal ("Printer ID: ");
- X sendbold (Printer);
- X
- X y -= SMALL_POINT + (SMALL_POINT / 2);
- X printf ("%d %d moveto\n", x,y);
- X sendnormal ("Options: ");
- X sendbold (Options);
- X
- X y -= SMALL_POINT + (SMALL_POINT / 2);
- X printf ("%d %d moveto\n", x,y);
- X sendnormal ("Date: ");
- X sendbold (Date);
- X
- X y -= SMALL_POINT + (SMALL_POINT / 2);
- X printf ("%d %d moveto\n", x,y);
- X sendnormal ("Machine: ");
- X sendbold (Machineid);
- X
- X send ("showpage pg restore\n");
- X send ("%%Trailer\n");
- X exit (0);
- X}
- X
- Xsend (s)
- Xchar *s;
- X{
- X while (*s)
- X putchar (*s++);
- X}
- X
- Xsendnormal (s)
- Xchar *s;
- X{
- X printf ("/Courier findfont %d scalefont setfont\n", SMALL_POINT);
- X send ("(");
- X send (s);
- X send (")show\n");
- X}
- X
- Xsendbold (s)
- Xchar *s;
- X{
- X printf ("/Helvetica-Bold findfont %d scalefont setfont\n", SMALL_POINT);
- X send ("(");
- X send (s);
- X send (")show\n");
- X}
- X
- Xtrim (s)
- Xchar *s;
- X{
- X while (*s)
- X { if (*s < ' ')
- X { *s = 0;
- X break;
- X }
- X s++;
- X }
- X}
- X
- Xbad_file()
- X{
- X fprintf (stderr, "Bad %s file\n", PDEF);
- X exit (1);
- X}
- X
- Xcompare (a,b)
- Xchar *a, *b;
- X{ int aa, bb;
- X
- X while (*a && *b)
- X { aa = *a++;
- X bb = *b++;
- X if (toupper (aa) != toupper (bb))
- X return (aa - bb);
- X }
- X return (0);
- X}
- X
- END_OF_FILE
- if test 7088 -ne `wc -c <'psbanner.c'`; then
- echo shar: \"'psbanner.c'\" unpacked with wrong size!
- fi
- # end of 'psbanner.c'
- fi
- if test -f 'psd.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'psd.c'\"
- else
- echo shar: Extracting \"'psd.c'\" \(10733 characters\)
- sed "s/^X//" >'psd.c' <<'END_OF_FILE'
- X/* ta=4 */
- X
- X/****************************************************************************
- X* p s d . c v2.0 *
- X* *
- X* Filter a "single sided" document to become a "double sided document" *
- X* *
- X* Tony Field. tony@ajfcal *
- X* *
- X* The basic algorithm for "print_book()" was based on a routine written *
- X* by Tom Neff (tneff@well.uucp) named "book" which printed 5.5x8.5 *
- X* double sided on an HP LaserJet. *
- X****************************************************************************/
- X/*
- X A number of comments could be made about psd:
- X 1. it does work.
- X 2. it could work a lot better
- X 3. output is minimally conforming to postscript
- X 4. input is "similar to" postscript
- X
- X the psf-generated control information is assumed to be at the
- X end of the postscript print file. The postscript file must contain
- X a line like:
- X %PsfPtr: 21118
- X
- X If the %PsPtr line is missing, then the file is NOT a book format.
- X The format of this information is described in function read_control().
- X
- X psd does little to normal double sided print other than to change
- X the order in which the pages are printed. It also adjusts the
- X %%Pages: value to reflect the actual page count printed.
- X
- X psd re-inserts translation, rotation and scale information eliminated
- X by psf if the double sided print is to make an 8.5x5.5 "book".
- X
- X Of course, a bunch of "very ugly" logic is needed for the "book"
- X format to re-insert the postscript for page control - but it does work...
- X*/
- X
- X#include <stdio.h>
- X#include <string.h>
- X
- X/* If books are made by generating two print files with the -s side count
- X then set SIDECOUNT = 0 (i.e. no alternate paper hopper is available.
- X
- X If books are made by switching to the alternate print hopper for
- X the second side, then set SIDECOUNT = 3 (i.e. second hopper is available
- X*/
- X
- X#define SIDECOUNT 0
- X
- X#define LONG_STR 1000
- X#define MAX_PAGE 1000
- X
- Xstatic int nsheets, nhalves;
- Xstatic int row;
- Xstatic int lpage, rpage;
- X
- Xchar slots[4][100] =
- X{ "statusdict begin 1 setpapertray end",
- X "statusdict begin 2 setpapertray end",
- X "",
- X ""
- X} ;
- Xint nslots = 2;
- X
- Xchar line[LONG_STR + 1];
- Xchar scale[100];
- Xint max_frame;
- Xint landscape;
- Xint real_width;
- Xint height;
- Xint width;
- Xint dx_home[4];
- Xint dy_home[4];
- Xint npage;
- Xlong pg_loc[MAX_PAGE];
- Xlong trailer_loc;
- Xint phys_page;
- Xint side;
- Xint bookwork;
- Xint alternate_tray = 0;
- Xint second_side = 0;
- X
- XFILE *input_fp;
- XFILE *output_fp;
- X
- Xchar *pgmname;
- X
- Xmain(argc, argv)
- Xint argc;
- Xchar *argv[];
- X{ int c;
- X extern char *optarg;
- X extern int optind;
- X FILE *pdef;
- X
- X side = SIDECOUNT; /* print size 1, 2, or both = 3 */
- X
- X if ((pdef = fopen (PDEF, "r")) != NULL)
- X { nslots = 0;
- X while (fgets (line, LONG_STR - 1, pdef) != NULL)
- X { trim (line);
- X if (strncmp (line, "*slots", 6) == 0)
- X { while (fgets (line, 90, pdef) != NULL)
- X { trim (line);
- X if (strncmp (line, "*eof", 4) == 0)
- X break;
- X if (*line)
- X {
- X strcpy (slots[nslots], line);
- X if (++nslots > 3)
- X break;
- X }
- X }
- X }
- X }
- X fclose (pdef);
- X }
- X
- X pgmname = argv[0];
- X if (argc > 1 && strcmp (argv[1], "-") == 0)
- X usage ();
- X
- X while ((c = getopt(argc, argv, "123-")) != -1)
- X { switch (c)
- X {
- X case '1':
- X case '2':
- X case '3':
- X side = c - '0';
- X break;
- X
- X default:
- X usage ();
- X }
- X }
- X if (side == 3 && nslots < 2)
- X { fprintf (stderr, "Cannot use -3: only one output tray\n");
- X exit (1);
- X }
- X
- X if (side <= 0 || side >= 4)
- X { fprintf (stderr, "Print side must be 1, 2, or 3\n");
- X exit (1);
- X }
- X if (optind >= argc)
- X usage ();
- X
- X output_fp = stdout;
- X
- X if ((input_fp = fopen(argv[optind], "r")) == NULL)
- X {
- X fprintf(stderr, "%s: Error opening %s!\n", pgmname, argv[1]);
- X exit (1);
- X }
- X read_control (input_fp);
- X get_prologue ();
- X if (bookwork)
- X print_book ();
- X else
- X print_double ();
- X get_trailer ();
- X exit (0);
- X}
- X
- X/****************************************************************************
- X* read_control() *
- X* Read the control information at the end of the file for the page *
- X* dimensions and byte address of the start of each page. *
- X* Each of the parameter lines is a comment with the form %Psfxxxx: yyyy *
- X****************************************************************************/
- X
- Xread_control (fp)
- XFILE *fp;
- X{ char tail[100];
- X int i, j;
- X long atol(), psfloc;
- X
- X /* %PsfPtr: xxx --> xxx is the pointer to the first %Psf... line
- X in the file. Seek to the indicated byte position to begin
- X reading the Psf generated information which looks like:
- X
- X %%Trailer <--- (a)
- X %%DocumentFonts: Courier
- X %%Pages: 8
- X %PsfScale: 0.63194 0.79558 scale <--- (b)
- X %PsfMargin: 2 1 612 769 626
- X %PsfHome: 0 0 0
- X %PsfHome: 1 626 0
- X %PsfHome: 2 0 0
- X %PsfHome: 3 0 0
- X %PsfPg: 0 405 <--- byte offsets to page
- X %PsfPg: 1 3885
- X %PsfPg: 2 7023
- X ...
- X %PsfPg: 9999 21072 <--- points to (a) above
- X %PsfPtr: 21118 <--- points to (b) above
- X <ctrl/d>
- X */
- X fseek (fp, -50L, 2);
- X fread (tail, 50, 1, fp);
- X if ((i = tscan (tail, "%PsfPtr:")) == -1)
- X { fprintf (stderr, "%s: File is not in psf book format\n", pgmname);
- X exit (1);
- X }
- X psfloc = atol (tail + i + 9); /* beginning of psf information */
- X fseek (fp, psfloc, 0);
- X
- X fgets (scale, 99, fp);
- X strcpy (tail, scale + 11); /* get rid of the %psf comment */
- X strcpy (scale, tail);
- X
- X /* fetch psf data. */
- X /* %PsfMargin: */
- X fscanf (fp, "%s %d %d %d %d %d", tail,
- X &max_frame, &landscape, &real_width, &height, &width);
- X
- X bookwork = max_frame == 2 && landscape;
- X for (i = 0; i < 4; i++) /* %PsfHome: */
- X fscanf (fp, "%s %d %d %d", tail, &j, &dx_home[i], &dy_home[i]);
- X
- X npage = 0; /* %PsfPg: */
- X while (fscanf (fp, "%s %d %ld", tail, &i, &pg_loc[npage]) == 3)
- X {
- X if (i == 9999)
- X { trailer_loc = pg_loc[npage];
- X break;
- X }
- X npage++;
- X }
- X fseek (fp, 0L, 0);
- X}
- X
- X/****************************************************************************
- X* get_prologue() *
- X* Read the prologue and pass it directly to the output *
- X****************************************************************************/
- X
- Xget_prologue ()
- X{
- X fgets (line, LONG_STR, input_fp); /* skip the psf header */
- X fprintf (output_fp, "%%!PS-Adobe-\n"); /* write a valid header */
- X while (fgets (line, LONG_STR, input_fp) != NULL)
- X { if (strncmp (line, "%%Page:", 7) == 0)
- X break;
- X fputs (line, output_fp);
- X }
- X}
- X
- X/****************************************************************************
- X* get_trailer () *
- X* Read the trailer and pass it to the output. Modify the page count to *
- X* reflect the number of physical pages printed. *
- X* Remove any reference to the %Psf... lines. *
- X****************************************************************************/
- X
- Xget_trailer ()
- X{
- X if (phys_page == 0 || (bookwork && second_side))
- X fprintf (output_fp, "showpage pg restore\n");
- X if (alternate_tray == 2)
- X fprintf (output_fp, "%s\n", slots[0]);
- X fseek (input_fp, trailer_loc, 0);
- X while (fgets (line, LONG_STR, input_fp) != NULL)
- X { if (strncmp (line, "%%Pages:", 8) == 0)
- X fprintf (output_fp, "%%%%Pages: %d\n", phys_page);
- X else if (strncmp (line, "%Psf", 4) != 0)
- X fputs (line, output_fp);
- X }
- X}
- X
- X/****************************************************************************
- X* display_page() *
- X* Send all ouput that belongs to a specific page. For 8.5x5.5 books, *
- X* generate the scale, etc that was omitted by psf. Also enable the *
- X* alternate tray if it to be used. *
- X****************************************************************************/
- X
- Xdisplay_page (pgno, n)
- Xint pgno;
- Xint n;
- X{ static need_showpage = 0;
- X
- X fseek (input_fp, pg_loc[pgno], 0);
- X fgets (line, LONG_STR, input_fp);
- X if (n == 0)
- X {
- X if ((phys_page && bookwork) || need_showpage)
- X fprintf (output_fp, "showpage pg restore\n");
- X
- X if (alternate_tray == 1)
- X { alternate_tray = 2;
- X fprintf (output_fp, "%s\n", slots[1]);
- X }
- X fprintf (output_fp, "%%%%Page: ? %d\n", ++phys_page);
- X if ((bookwork && max_frame == 2) || pgno >= npage)
- X { fprintf (output_fp, "/pg save def\n");
- X }
- X need_showpage = pgno >= npage;
- X }
- X
- X if (bookwork)
- X { if (n == 0)
- X {
- X fprintf (output_fp, "90 rotate 0 %d translate\n", -real_width);
- X fprintf (output_fp, "%s", scale);
- X }
- X fprintf (output_fp, "%d %d translate\n", dx_home[n], dy_home[n]);
- X }
- X
- X if (pgno < npage)
- X { while (fgets (line, LONG_STR, input_fp) != NULL)
- X { if(strncmp (line, "%%", 2) == 0)
- X break;
- X fputs (line, output_fp);
- X }
- X }
- X}
- X
- X
- X/****************************************************************************
- X* print_book() *
- X* print_book() is based on Tom Neff's (tneff@well.uucp) "book" *
- X* for the HP LaserJet *
- X* Scan the text to ensure that the 8.5x.5.5 pages are constructed in *
- X* such a way that a "book" is generated - simply staple in the middle . *
- X****************************************************************************/
- X
- Xprint_book ()
- X{ int done;
- X
- X nsheets = (npage+3)/4;
- X nhalves = nsheets*4;
- X phys_page = 0;
- X
- X if (side & 1)
- X { for (rpage=0, lpage=nhalves-1; rpage < lpage; rpage+=2, lpage-=2)
- X {
- X display_page (lpage, 0);
- X display_page (rpage, 1);
- X }
- X }
- X
- X if (side == 3)
- X alternate_tray = 1;
- X
- X if ((side & 2) && nhalves > 1)
- X { second_side = 1;
- X for (rpage=nhalves/2, lpage=rpage-1; lpage >= 0; rpage+=2, lpage-=2)
- X {
- X display_page (lpage, 0);
- X display_page (rpage, 1);
- X }
- X }
- X}
- X
- X/****************************************************************************
- X* print double() *
- X* print double sided pages. first odd numbered, then even numbered. *
- X****************************************************************************/
- X
- Xprint_double()
- X{
- X nsheets = (npage+1)/2;
- X phys_page = 0;
- X
- X if (side & 1)
- X { for (rpage=0; rpage < nsheets; rpage++)
- X {
- X display_page (rpage * 2, 0);
- X }
- X }
- X
- X if (side == 3)
- X alternate_tray = 1;
- X
- X if (side & 2 && npage > 1)
- X { second_side = 1;
- X for (rpage=nsheets - 1; rpage >= 0; rpage--)
- X {
- X display_page (rpage * 2 + 1, 0);
- X }
- X }
- X}
- X
- X
- Xtscan (s, t) /* search for string t in s */
- Xchar s[], t[];
- X{
- X int i, j, k;
- X for (i = 0; s[i] != '\0'; i++)
- X { for (j = i, k=0; t[k] != '\0' && s[j] == t[k]; j++, k++)
- X ;
- X if (t[k] == '\0')
- X return (i);
- X }
- X return (-1);
- X}
- Xusage ()
- X{
- X printf ("Usage: psd -n file\n");
- X printf (" where: n = side number to print\n");
- X printf (" -1 = print side 1 only\n");
- X printf (" -2 = print side 2 only\n");
- X printf (" -3 = print both sides in one pass\n");
- X printf (" file = print this file\n");
- X exit (0);
- X}
- X
- Xtrim (s)
- Xchar *s;
- X{
- X while (*s)
- X { if (*s < ' ')
- X { *s = 0;
- X break;
- X }
- X s++;
- X }
- X}
- END_OF_FILE
- if test 10733 -ne `wc -c <'psd.c'`; then
- echo shar: \"'psd.c'\" unpacked with wrong size!
- fi
- # end of 'psd.c'
- fi
- if test -f 'table.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'table.c'\"
- else
- echo shar: Extracting \"'table.c'\" \(8192 characters\)
- sed "s/^X//" >'table.c' <<'END_OF_FILE'
- X/* ta=4 */
- X/************************************************************************
- X* t a b l e . c *
- X* *
- X* Generate the *.def tables required by psf to describe a printer *
- X* *
- X* Scans the Adobe *.ppd files for specific parametric lines. *
- X************************************************************************/
- X
- X/* Usage: table files.ppd ... destination.dir
- X
- X where: files.ppd are the various .ppd files to be converted.
- X destination.dir is the destination directory in which
- X to place the generated .def file(s)
- X
- X The layout of the generated .def files is:
- X
- XNEC LC-890 v47.0 (modified) <-- printer name for installpsf
- X (from *Nickname)
- XLetter <-- user name (e.g. psf -g Letter)
- X (from *PageSize)
- Xstatusdict begin lettertray end <-- actual postscript to select size
- X (from *PageSize)
- X 612 792 18 15 599 776 <-- page width page height LLx LLy URx URy
- X (page width/height from *PaperDimension)
- X (LLx LLy URx URy from *ImageableArea)
- XLegal
- Xstatusdict begin legaltray end
- X 612 1008 18 19 593 990
- XA4
- Xstatusdict begin a4tray end
- X 595 842 10 8 585 813
- XB5
- Xstatusdict begin b5tray end
- X 516 729 18 7 482 702
- X*fonts <-- marker for fonts
- XAvantGarde-Book <-- real font names in font dictionary
- XAvantGarde-Demi (from *Font)
- XBookman-Demi
- XBookman-Light
- XCourier
- XHelvetica
- XHelvetica-Narrow
- XNewCenturySchlbk-Roman
- XPalatino-Roman
- XSymbol
- XTimes-Roman
- XZapfChancery-MediumItalic
- XZapfDingbats
- X*slots <-- marker for paper tray select
- Xstatusdict begin 1 setpapertray end <-- select first tray
- Xstatusdict begin 2 setpapertray end <-- select second tray etc..
- X (from *InputSlot)
- X*eof <-- logical end of file
- X*/
- X
- X#include <stdio.h>
- X#include <string.h>
- X#include <sys/types.h>
- X#include <sys/stat.h>
- X
- Xchar nickname[200];
- Xstruct pdef
- X{
- X char name[500];
- X char set[500];
- X char tray[500];
- X int lx, ly, ux, uy, sx, sy;
- X} ;
- X
- Xchar *malloc();
- Xchar pname[100];
- Xstruct pdef printer[40], pblank;
- Xint nprinter = 0;
- Xchar *fonts[100];
- Xchar *slots[10];
- Xint nfonts=0;
- Xint nslots=0;
- X
- Xmain (argc,argv)
- Xint argc;
- Xchar *argv[];
- X{
- X char *fname;
- X FILE *fp_in, *fp_out;
- X int i, j;
- X char *c;
- X char outname[100], fnonly[50];
- X char *destdir;
- X
- X if (argc < 3)
- X usage ();
- X
- X argc--;
- X destdir = argv[argc];
- X if (isdir (destdir) != 1)
- X usage ();
- X
- X for (i = 1; i < argc; i++)
- X { if ((fp_in = fopen (argv[i], "r")) != NULL)
- X {
- X for (j = 0; j < nprinter; j++)
- X printer[j] = pblank;
- X
- X for (j = 0; j < nfonts; j++)
- X free (fonts[j]);
- X
- X for (j = 0; j < nslots; j++)
- X free (slots[j]);
- X
- X nfonts = nslots = nprinter = 0;
- X
- X fnameonly (argv[i], fnonly);
- X if ((c = strchr(fnonly, '.')))
- X *c = '\0';
- X strcpy (outname,destdir);
- X strcat (outname, "/");
- X strcat (outname, fnonly);
- X strcat (outname, ".def");
- X
- X if ((fp_out = fopen (outname, "w")) == NULL)
- X { fprintf (stderr, "%s: cannot create file %s\n", argv[0], outname);
- X exit (1);
- X }
- X build (fp_in);
- X display (fp_out);
- X fclose (fp_out);
- X
- X fclose (fp_in);
- X }
- X }
- X
- X}
- X
- Xbuild (fp_in)
- XFILE *fp_in;
- X{
- X char s[1000];
- X int n;
- X int a, b, c, d;
- X char which[500];
- X
- X
- X while (fgets (s, 999, fp_in) != NULL)
- X { trim (s);
- X
- X if (strncmp (s, "*PageSize", 9) == 0)
- X {
- X n = ptype (s, which);
- X gettext (s, printer[n].set);
- X }
- X else if (strncmp (s, "*NickName:", 10) == 0)
- X {
- X gettext (s, nickname);
- X }
- X else if (strncmp (s, "*Font ", 6) == 0)
- X {
- X ftype (s);
- X }
- X else if (strncmp (s, "*PaperTray", 10) == 0)
- X {
- X n = ptype (s, which);
- X gettext (s, printer[n].tray);
- X }
- X else if (strncmp (s, "*InputSlot", 10) == 0)
- X {
- X gettext (s, which);
- X slots[nslots] = malloc (strlen(which) + 2);
- X strcpy (slots[nslots], which);
- X nslots++;
- X }
- X else if (strncmp (s, "*ImageableArea", 14) == 0)
- X {
- X n = ptype (s, which);
- X sscanf (strchr (s, '"') + 1, "%d%d%d%d", &a, &b, &c, &d);
- X printer[n].lx = a;
- X printer[n].ly = b;
- X printer[n].ux = c;
- X printer[n].uy = d;
- X }
- X else if (strncmp (s, "*PaperDimension", 15) == 0)
- X {
- X n = ptype (s, which);
- X sscanf (strchr (s, '"') + 1, "%d %d", &a, &b);
- X printer[n].sx = a;
- X printer[n].sy = b;
- X }
- X }
- X}
- X
- X
- Xptype (s, which)
- Xchar *s, *which;
- X{
- X char *w, *ww;
- X int i;
- X
- X w = s;
- X while (*w++ != ' ')
- X ;
- X ww = which;
- X while (*w != ':')
- X {
- X if (*w == '/')
- X {
- X
- X while (*w++ != ':')
- X ;
- X break;
- X/*
- X ww = which;
- X w++;
- X continue;
- X*/
- X }
- X if (*w == ' ')
- X *w = '-';
- X *ww++ = *w++;
- X }
- X *ww = '\0';
- X while (*w == ' ')
- X w++;
- X/*
- X sscanf (s, "%*s%s", which);
- X*/
- X/*
- X w = which;
- X while (*w)
- X { if (*w == ':')
- X { *w = '\0';
- X break;
- X }
- X w++;
- X }
- X*/
- X for (i = 0; i < nprinter; i++)
- X { if (strcmp (which, printer[i].name) == 0)
- X return (i);
- X }
- X strcpy (printer[nprinter].name, which);
- X nprinter++;
- X return (nprinter - 1);
- X}
- X
- Xftype (s)
- Xchar *s;
- X{
- X char *w, *ww;
- X char which[100];
- X int i;
- X
- X w = s;
- X while (*w++ != ' ')
- X ;
- X ww = which;
- X while (*w != ':')
- X {
- X if (*w == ' ')
- X *w = '-';
- X *ww++ = *w++;
- X }
- X *ww = '\0';
- X while (*w == ' ')
- X w++;
- X
- X if (strncmp (which, "Za", 2))
- X { if (tscan (which, "Bold") >= 0 || tscan (which,"Italic") >= 0
- X || tscan (which,"Obliq") >= 0)
- X return;
- X }
- X
- X fonts[nfonts] = malloc (strlen (which) + 1);
- X strcpy (fonts[nfonts++], which);
- X
- X}
- X
- X
- Xdisplay (fp_out)
- XFILE *fp_out;
- X{
- X int i;
- X
- X fprintf (fp_out, "%s\n", nickname);
- X for (i = 0; i < nprinter; i++)
- X {
- X fprintf (fp_out, "%s\n%s\n", printer[i].name, printer[i].set);
- X fprintf (fp_out, "%5d %5d %5d %5d %5d %5d\n",
- X printer[i].sx, printer[i].sy,
- X printer[i].lx, printer[i].ly, printer[i].ux, printer[i].uy);
- X
- X/* print the actual size of the image area
- X
- X printf ("%-20s %-20s %4d %4d\n", pname, printer[i].name,
- X printer[i].ux - printer[i].lx + 1,
- X printer[i].uy - printer[i].ly + 1);
- X*/
- X }
- X
- X fprintf (fp_out, "*fonts\n");
- X for (i = 0; i < nfonts; i++)
- X fprintf (fp_out, "%s\n", fonts[i]);
- X
- X fprintf (fp_out, "*slots\n");
- X for (i = 0; i < nslots; i++)
- X fprintf (fp_out, "%s\n", slots[i]);
- X fprintf (fp_out, "*eof\n");
- X}
- X
- Xgettext (s, t)
- Xchar *s, *t;
- X{
- X strcpy (t, strchr (s, '"') + 1);
- X while (*t)
- X { if (*t == '"')
- X { *t = '\0';
- X break;
- X }
- X t++;
- X }
- X}
- X
- Xtscan (s, t)
- Xchar s[], t[];
- X{
- X int i, j, k;
- X for (i = 0; s[i] != '\0'; i++)
- X { for (j = i, k=0; t[k] != '\0' && s[j] == t[k]; j++, k++)
- X ;
- X if (t[k] == '\0')
- X return (i);
- X }
- X return (-1);
- X}
- X
- Xtrim (s)
- Xchar *s;
- X{
- X while (*s)
- X { if (*s < ' ')
- X { *s = '\0';
- X break;
- X }
- X s++;
- X }
- X}
- X
- X
- Xfnameonly (path, fn)
- Xchar *path, *fn;
- X{
- X char *strrchr(), *where;
- X
- X if ((where = strrchr (path, '/')) == NULL)
- X strcpy (fn, path);
- X else
- X strcpy (fn, where + 1);
- X return;
- X}
- X
- X
- X/****************************************************************************
- X* isdir (name) *
- X* *
- X* See if the 'name' is a directory entry. If so, return 1. If not, *
- X* return a 0. *
- X* *
- X* A call to stat() returns a bunch of parameters into 'buf' that *
- X* essentially decodes the inode of the file into useful information. *
- X* The st_node variable indicate the type of file. Examine the stat.h *
- X* file to see all possible file types. For this routine, we are *
- X* interested only in the bits S_IFMT (0170000 mask) of st_mode. If these *
- X* bits are S_IFDR (0040000), then we have a directory, otherwise not. *
- X****************************************************************************/
- X
- Xisdir (name)
- Xchar *name;
- X{
- X struct stat buf;
- X
- X if (stat (name, &buf) != 0) /* ensure stat() is happy */
- X return (-1);
- X if ((buf.st_mode & S_IFMT) == S_IFDIR) /* good call, see if */
- X return (1); /* is directory */
- X if ((buf.st_mode & S_IFMT) == S_IFREG) /* good call, see if */
- X return (0); /* is file */
- X return (-1); /* something else */
- X}
- X
- Xusage ()
- X{ fprintf (stderr, "Usage: table f.ppd f.ppd ... /dest.dir\n");
- X fprintf (stderr, " where f.ppd = source .ppd files\n");
- X fprintf (stderr, " dest.dir = desination directory for .def files\n");
- X exit (1);
- X}
- X
- END_OF_FILE
- if test 8192 -ne `wc -c <'table.c'`; then
- echo shar: \"'table.c'\" unpacked with wrong size!
- fi
- # end of 'table.c'
- fi
- echo shar: End of archive 4 \(of 6\).
- cp /dev/null ark4isdone
- MISSING=""
- for I in 1 2 3 4 5 6 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 6 archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-
-